package com.it.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

// TODO SpringMVC (1)、声明式异常的使用

/**
 * 【说明】：配置全局异常
 */
@RestController
@RequestMapping("/error")
public class springmvc01 {
    /**
     * 测试空指针异常
     */
    @GetMapping("/data1")
    public String data1() {
        String name = null;
        name.toString();
        return "测试空指针异常";
    }

    /**
     * 测试算数异常
     */
    @GetMapping("/data2")
    public String data2() {
        int i = 10 / 0;
        return "测试算数异常";
    }

}
